import 'package:OASys/entity/MeetingInfoVo.dart';
import 'package:OASys/entity/MeetingVo.dart';
import 'package:OASys/httpConfig/DioManager.dart';
import 'package:OASys/httpConfig/ErrorEntity.dart';
import 'package:OASys/httpConfig/NWMethod.dart';

class MeetingApi {
  void info(int id,
      {Function(MeetingInfoVo) success, Function(ErrorEntity) error}) {
    DioManager().request<MeetingInfoVo>(
      NWMethod.GET,
      "/front/meeting/info/$id",
      success: success,
      error: error,
    );
  }

  void list(int page, int limit,
      {MeetingVo andQuery,
      Function(List<MeetingVo>) success,
      Function(ErrorEntity) error}) {
    DioManager().requestList<MeetingVo>(
      NWMethod.POST,
      "/front/meeting/list",
      params: {
        "page": page,
        "limit": limit,
        "andQuery": andQuery,
      },
      success: success,
      error: error,
    );
  }

  void myMeeting(int page, int limit,
      {MeetingVo andQuery,
      Function(List<MeetingVo>) success,
      Function(ErrorEntity) error}) {
    DioManager().requestList<MeetingVo>(
      NWMethod.POST,
      "/front/meeting/myMeeting",
      params: {
        "page": page,
        "limit": limit,
        "andQuery": andQuery,
      },
      success: success,
      error: error,
    );
  }

  void partMeeting(int page, int limit,
      {Function(List<MeetingVo>) success, Function(ErrorEntity) error}) {
    DioManager().requestList<MeetingVo>(
      NWMethod.POST,
      "/front/meeting/partMeeting",
      params: {
        "page": page,
        "limit": limit,
      },
      success: success,
      error: error,
    );
  }

  void save(MeetingInfoVo info,
      {Function(String) success, Function(ErrorEntity) error}) {
    DioManager().request<String>(
      NWMethod.POST,
      "/front/meeting/save",
      params: info.toJson(),
      success: success,
      error: error,
    );
  }

  void remove(int id, {Function(String) success, Function(ErrorEntity) error}) {
    DioManager().request<String>(
      NWMethod.DELETE,
      "/front/meeting/remove/$id",
      success: success,
      error: error,
    );
  }

  void end(int id, {Function(String) success, Function(ErrorEntity) error}) {
    DioManager().request<String>(
      NWMethod.GET,
      "/front/meeting/end/$id",
      success: success,
      error: error,
    );
  }

  void start(int id, {Function(String) success, Function(ErrorEntity) error}) {
    DioManager().request<String>(
      NWMethod.GET,
      "/front/meeting/start/$id",
      success: success,
      error: error,
    );
  }
}
